<!doctype html>
<html xmlns:th="http://www.thymeleaf.org" >
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>登录</title>

    <!-- Bootstrap core CSS -->
    <script src="/webjars/jquery/3.3.1/jquery.min.js"></script>
    <script src="/webjars/bootstrap/4.0.0/js/bootstrap.min.js"></script>
    <link href="/webjars/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
    <meta name="theme-color" content="#563d7c">


    <style>
        .bd-placeholder-img {
            font-size: 1.125rem;
            text-anchor: middle;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
        }

        @media (min-width: 768px) {
            .bd-placeholder-img-lg {
                font-size: 3.5rem;
            }
        }
    </style>
    <!-- Custom styles for this template -->
    <link href="/css/login.css" rel="stylesheet">
    <style>
        body{background:url(img/background.jpg) top right;
            background-size:100%;
            background-repeat:no-repeat;}
    </style>
</head>
<body class="text-center">
<div class="form-signin">
    <img class="mb-4" src="/img/logo.png" alt="" width="72" height="72">
    <h1 class="h3 mb-3 font-weight-normal text-gray-800">请登录</h1>
    <label for="username" class="sr-only">登录账号</label>
    <input type="text" id="username" name="username" class="form-control" placeholder="账号" required autofocus>
    <label for="password" class="sr-only">Password</label>
    <input type="password" id="password" name="password" class="form-control" placeholder="密码" required>
    <div class="checkbox mb-3">
        <label>
            <input type="checkbox" id="rememberMe" name="rememberMe" > <span class="text-white">记住我</span>
        </label>
    </div>

    <button class="btn btn-lg btn-primary btn-block" id="submitBtn" onclick="submit_f()">Sign in</button>
    <div id="tip_msg"></div>
    <p class="mt-5 mb-3 text-muted" >&copy; yuec</p>
</div>

</body>
</html>

<script>
    function submit_f() {
        var username = $("#username").val();
        var password = $("#password").val();
        var rememberMe = $("#rememberMe").is(':checked')==false?false:true;
        $.post(
            "login",
            {
                username: username,
                password: password,
                rememberMe: rememberMe
            },
            function (data) {
                if (data.code == "0") {
                    window.location.href = "/index"
                } else {
                    var htm="<div class=\"alert alert-danger\" role=\"alert\" >"+data.code + ":" + data.msg+"</div>"
                    $('#tip_msg').append(htm)
                }
            })
    }
</script>